var RunLayer01 = cc.Layer.extend({
	arr:null,
	scene:null,
	runSpriteSheet:null,
	arrSpriteSheet:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 2);
		this.init();
	},
	init:function () {
		this.initSpriteCache();
		this.initSprite();
		this.initPosition();
		this.initLiteLayer();
		this.initLite2Layer();
		this.initAAWin();
		this.initLite3Layer();

// var listener_mouse = cc.EventListener.create({
// event: cc.EventListener.MOUSE,
// onMouseDown: function(event){
// var pos = cc.p(event.getLocationX(),event.getLocationY());
// var target = event.getCurrentTarget();
// var help = new Listener();
// help.executeDown(pos,target);
// }
// });
// cc.eventManager.addListener(listener_mouse, this);
		var listener_touch = cc.EventListener.create({
			event: cc.EventListener.TOUCH_ONE_BY_ONE,
			onTouchBegan:function(touch, event) {
				var pos = cc.p(touch.getLocationX(),touch.getLocationY());
				var target = event.getCurrentTarget();
				var help = new Listener();
				help.executeDown(pos,target);
				return true;
			}
		});
		cc.eventManager.addListener(listener_touch, this);
	},
	initSpriteCache:function () {
		this.runSpriteSheet = new cc.Node();
		this.addChild(this.runSpriteSheet,10);
		this.arrSpriteSheet = new cc.Node();
		this.addChild(this.arrSpriteSheet,100);
		
		this.arr = new Arrow01(this.getParent(),"#button/arr0.png");
		this.arrSpriteSheet.addChild(this.arr, 10);
	},
	initSprite:function () {
		// 桌子
		this.desk = new Angel01("#desk01.png");
		// 主机
		this.host = new Angel01("#host.png");
		// 开机按钮
		this.host_button = new Angel01("#host_close.png");
		// 电脑
		this.comper = new Angel01("#comper_close.png");
		// 鼠标
		this.mouse = new Angel01("#mouse.png");
		// 原子吸收
		this.atomic = new Angel01("#atomic.png");
		this.atomic_p = new Angel01("#atomic2.png");
		// 电源
		this.power = new Angel01("#power.png");
		// 气瓶柜
		this.gas = new Angel01("#gas1.png");
		// 气瓶柜-刻度表
		this.gas_table = new Angel01("#table1.png");
		// 气瓶柜-指针
		this.gas_point = new GasPointer("#gas_point.png");
		// 气瓶柜-转轮
		this.gas_runner = new Angel01("#runner1.png");
		// 空气压缩机
		this.air = new Angel01("#air.png");
		// 烧杯
		this.beaker = new Flask("#beaker.png");
		this.beaker_label = new cc.LabelBMFont("标\n样\n1", res01.font_f);
		this.beaker2 = new Flask("#beaker.png");
		this.beaker2_label = new cc.LabelBMFont("标\n样\n2", res01.font_f);
		this.beaker3 = new Flask("#beaker.png");
		this.beaker3_label = new cc.LabelBMFont("标\n样\n3", res01.font_f);
		this.beaker4 = new Flask("#beaker.png");
		this.beaker4_label = new cc.LabelBMFont("标\n样\n4", res01.font_f);
		this.beaker5 = new Flask("#beaker.png");
		this.beaker5_label = new cc.LabelBMFont("空\n白\n", res01.font_f);
		
		// 油烟机
		this.cooker = new Angel01("#cooker.png");
		
		this.gas_table.setVisible(false);
		this.gas_point.setVisible(false);
		this.gas_runner.setVisible(false);
		
		this.runSpriteSheet.addChild(this.desk,1,TAG_RUN_DESK);
		this.runSpriteSheet.addChild(this.host,2,TAG_RUN_HOST);
		this.runSpriteSheet.addChild(this.host_button,2,TAG_HOST_OPEN);
		this.runSpriteSheet.addChild(this.comper,2,TAG_RUN_COMPER);
		this.runSpriteSheet.addChild(this.mouse,2,TAG_RUN_COMPER);
		this.runSpriteSheet.addChild(this.atomic,2,TAG_RUN_ATOMIC);
		this.runSpriteSheet.addChild(this.atomic_p,2,TAG_RUN_ATOMIC_P);
		this.runSpriteSheet.addChild(this.power,2,TAG_RUN_POWER);
		this.runSpriteSheet.addChild(this.gas,2,TAG_RUN_GAS);
		this.runSpriteSheet.addChild(this.air,2,TAG_RUN_AIR);
		this.runSpriteSheet.addChild(this.beaker,3,TAG_RUN_BEAKER);
		this.runSpriteSheet.addChild(this.beaker2,3,TAG_RUN_BEAKER2);
		this.runSpriteSheet.addChild(this.beaker3,3,TAG_RUN_BEAKER3);
		this.runSpriteSheet.addChild(this.beaker4,3,TAG_RUN_BEAKER4);
		this.runSpriteSheet.addChild(this.beaker5,3,TAG_RUN_BEAKER5);
		this.runSpriteSheet.addChild(this.cooker,2,TAG_RUN_COOKER);
		this.runSpriteSheet.addChild(this.gas_table,2,TAG_GAS_TABLE);
		this.runSpriteSheet.addChild(this.gas_point,2,TAG_GAS_POINT);
		this.runSpriteSheet.addChild(this.gas_runner,2,TAG_GAS_RUNNER);
		this.addChild(this.beaker_label,11);
		this.addChild(this.beaker2_label,11);
		this.addChild(this.beaker3_label,11);
		this.addChild(this.beaker4_label,11);
		this.addChild(this.beaker5_label,11);
	},
	initPosition:function () {
		var marign = 1;
		var marign2 = 5;
		this.desk.setPosition(0, gg.height * 0.1);
		var deskHeight = gg.height * 0.1 + this.desk.height - gg.height * 0.03;
		var deskWidht = gg.width * 0.01 + this.desk.width;
		this.host.setPosition(gg.width * 0.04, deskHeight);
		this.host_button.setPosition(this.host.x + this.host.width * 0.38 - 5, this.host.y + this.host.height * 0.62 - 5);
		this.comper.setPosition(this.host.x + this.host.width, deskHeight);
		this.mouse.setPosition(this.comper.x + this.comper.width, deskHeight);
		this.atomic.setPosition(this.mouse.x + this.mouse.width, deskHeight);
		this.atomic_p.setPosition(this.atomic.x, deskHeight);
		this.atomic_p.setVisible(false);
		this.cooker.setPosition(this.mouse.x + this.mouse.width + marign + 70, gg.height - this.cooker.height - 86);
		this.power.setPosition(this.atomic.x + this.atomic.width + marign, deskHeight);
		this.air.setPosition(this.atomic.x + this.atomic.width, gg.height * 0.1);
		this.beaker.setPosition(this.power.x + this.power.width + marign2, deskHeight - 10);
		this.beaker_label.setColor(cc.color(0,0,0,0));
		this.beaker_label.setPosition(this.beaker.x, this.beaker.y + this.beaker.height + marign);
		this.beaker2.setPosition(this.beaker.x + this.beaker.width + marign2, deskHeight - 10);
		this.beaker2_label.setColor(cc.color(0,0,0,0));
		this.beaker2_label.setPosition(this.beaker2.x, this.beaker2.y + this.beaker2.height + marign);
		this.beaker3.setPosition(this.beaker2.x + this.beaker2.width + marign2, deskHeight - 10);
		this.beaker3_label.setColor(cc.color(0,0,0,0));
		this.beaker3_label.setPosition(this.beaker3.x, this.beaker3.y + this.beaker3.height + marign);
		this.beaker4.setPosition(this.beaker3.x + this.beaker3.width + marign2, deskHeight - 10);
		this.beaker4_label.setColor(cc.color(0,0,0,0));
		this.beaker4_label.setPosition(this.beaker4.x, this.beaker4.y + this.beaker4.height + marign);
		this.beaker5.setPosition(this.beaker4.x + this.beaker4.width + marign2, deskHeight - 10);
		this.beaker5_label.setColor(cc.color(0,0,0,0));
		this.beaker5_label.setPosition(this.beaker5.x, this.beaker5.y + this.beaker5.height + marign);
		this.gas.setPosition(deskWidht, gg.height * 0.1);
		this.gas_table.setPosition(deskWidht + this.gas.width * 0.6, gg.height * 0.55);
		this.gas_runner.setPosition(deskWidht + this.gas.width * 0.6, gg.height * 0.5);
		
		this.gas_point.setAnchorPoint(19/29,9/15);
		this.gas_point.setPosition(deskWidht + this.gas.width * 0.6 + 25, gg.height * 0.55 + 25);
		
		flaskX = this.atomic_p.x + this.atomic_p.width * 0.38;
		flaskY = this.beaker.y;
	},
	initLiteLayer:/**
					 * 隐藏界面
					 */
	function () {
		this.lamp = new Angel01(res01.lite);
		this.lamp.setPosition(gg.width * 0.2, gg.height * 0.1);
		this.lamp.setVisible(false);
		this.addChild(this.lamp, 20);
		
		this.atomic_host = new Angel01("#atomic_host.png");
		this.atomic_host.setPosition(this.lamp.width * 0.4,this.lamp.height * 0.4);
		this.lamp.addChild(this.atomic_host, 10);
		
		this.atomic_part = new AtomicPart(this.lamp,"#atomic_part1.png");
		this.atomic_part.setPosition(this.lamp.width * 0.4,this.lamp.height * 0.4);
		this.atomic_part.initAtomicPart();
		
		this.light_ca = new Light(this.lamp,"#light.png","Ca",11);
		this.light_ca.setPosition(30, 15);
		this.light_ca.setTag(TAG_LIGHT_CA);
		this.light_ca.setColor(new cc.color(0,0,0,0));
		
		this.light_cu = new Light(this.lamp,"#light.png","Cu",11);
		this.light_cu.setPosition(70, 15);
		this.light_cu.setColor(new cc.color(0,0,0,0));
		
		this.light_hg = new Light(this.lamp,"#light.png","Hg",11);
		this.light_hg.setPosition(110, 15);
		this.light_hg.setColor(new cc.color(0,0,0,0));
	},
	initLite2Layer:function(){
		this.atomic2 = new Angel01(res01.lite);
		this.atomic2.setPosition(gg.width * 0.2, gg.height * 0.1);
		this.atomic2.setVisible(false);
		this.addChild(this.atomic2, 20);
		
		this.atomic_big = new Angel01("#big_atomic.png");
		this.atomic_big.setPosition(this.atomic2.width * 0.2,this.atomic2.height * 0.2);
		this.atomic2.addChild(this.atomic_big, 10);
		
		this.atomic_button = new Angel01("#atomic_close.png");
		this.atomic_button.setPosition(this.atomic2.width * 0.28,this.atomic2.height * 0.22);
		var w = this.atomic_button.width * 2;
		var h = this.atomic_button.height * 2;
		var x = this.atomic_button.x - this.atomic_button.width * 0.5 + this.atomic2.x;
		var y = this.atomic_button.y - this.atomic_button.height * 0.5 + this.atomic2.y;
		this.atomic_button.diyRect = new cc.rect(x, y, w, h);
		this.atomic2.addChild(this.atomic_button, 11, TAG_ATOMIC_OPEN);
	},
	initLite3Layer:function(){
		lite_offsetX = gg.width * 0.2;
		lite_offsetY = gg.height * 0.1;
		this.air_lite = new Angel01(res01.lite);
		this.air_lite.setPosition(lite_offsetX, lite_offsetY);
		this.air_lite.setVisible(false);
		this.addChild(this.air_lite, 20);
		
		var w = this.air_lite.width;
		var h = this.air_lite.height;
		var x = this.air_lite.x;
		var y = this.air_lite.y;
		
		this.air_big = new Angel01("#air_big.png");
		this.air_big.setPosition(w * 0.2,h * 0.2);
		this.air_lite.addChild(this.air_big,10);
		
		this.air_point = new AirPointer("#air_point.png");
		this.air_point.setAnchorPoint(19/32,21/31);
		this.air_point.setPosition(270,220);
		this.air_lite.addChild(this.air_point,11);
		
		this.button_open = new Angel01("#air_close.png");
		this.button_open.setPosition(w * 0.33 - 5,h * 0.36);
		this.button_open.diyRect = new cc.rect(this.button_open.x + lite_offsetX,this.button_open.y + lite_offsetY,this.button_open.width,this.button_open.height);
		this.air_lite.addChild(this.button_open,11,TAG_AIR_OPEN);
		
		this.air_valve = new Angel01("#air_valve.png");
		this.air_valve.setPosition(w * 0.675 - 5,h * 0.37);
		this.air_valve.diyRect = new cc.rect(this.air_valve.x + lite_offsetX,this.air_valve.y + lite_offsetY,this.air_valve.width,this.air_valve.height);
		this.air_lite.addChild(this.air_valve,11,TAG_AIR_VALVE);
	},
	initAAWin:function(){
		this.aawin = new AAWin(this);
		this.aawin.setVisible(false);
	}
});